package cn.tedu.hongbeifang.controller;
import cn.tedu.hongbeifang.pojo.dto.BannerAddNewDTO;
import cn.tedu.hongbeifang.pojo.dto.BannerUpdateDTO;
import cn.tedu.hongbeifang.pojo.vo.BannerListItemVO;
import cn.tedu.hongbeifang.pojo.vo.BannerStandardVO;
import cn.tedu.hongbeifang.pojo.vo.CommentIndexVO;
import cn.tedu.hongbeifang.service.IBannerService;
import cn.tedu.hongbeifang.service.ICommentService;
import cn.tedu.hongbeifang.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.io.IOException;
import java.util.List;

/**
 * 处理相册相关请求的控制器类
 *
 * @author java@tedu.cn
 * @version 0.0.1
 */
@Api(tags = "03. 评论管理模块")
@Slf4j
@RestController
@RequestMapping("/comments")
@Validated
public class CommentController {

  @Autowired
  ICommentService commentService;

    public CommentController() {
        log.debug("创建控制器类对象：CommentController");
    }

    // http://localhost:9081/comments/remove
    @PostMapping("/{id:[0-9]+}/delete")
    @ApiOperation("删除某一条评论")
    @ApiOperationSupport(order = 20)
    public JsonResult<Void> deleteById(Long id) {
        log.debug("开始处理【删除某一条评论】的请求，参数：{}", id);
        commentService.deleteById(id);
        return JsonResult.ok();
    }

    @PostMapping("/{inFoId:[0-9]+}/delete-InfoId")
    @ApiOperation("删除某一条评论")
    @ApiOperationSupport(order = 20)
    public JsonResult<Void> deleteByInfoId(Long InfoId) {
        log.debug("开始处理【删除某一条评论】的请求，参数：{}", InfoId);
        commentService.deleteByInfoId(InfoId);
        return JsonResult.ok();
    }




    // http://localhost:9081/comments
    @GetMapping("")
    @ApiOperation("查询评论列表")
    @ApiOperationSupport(order = 420)
    public JsonResult<List<CommentIndexVO>> list() {
        log.debug("开始处理【查询轮播图列表】的请求，无参数");
        List<CommentIndexVO> commentIndexVOS = commentService.select();
        return JsonResult.ok(commentIndexVOS);
    }



}
